<template>
  <view class="page">
    <!-- 顶部用户信息 -->
    <view class="user-info">
      <view class="avatar">
        <image src="/static/avator.jpg" class="avatar-img"></image>
      </view>
      <view class="user-details">
        <text>姓名：{{user.name}}</text><br>
        <text>手机号：{{user.phonenumber}}</text><br>
        <text>剩余闪赋次数：{{totalVailbleCodeNumber}}次</text>
      </view>
     <!-- <view class="settings">
        <u-icon name="setting" size="30"></u-icon>
      </view> -->
    </view>

    <!-- 统计信息 -->
    <view class="stats" id="show">
      <!-- <view class="stat-item">
        <text>充值次数</text>
        <text>1次</text>
      </view> -->
     <!-- <view class="stat-item">
        <text>转让次数</text>
        <text>0次</text>
      </view> -->
    <!--  <view class="stat-item">
        <text>闪赋次数</text>
        <text>0次</text>
      </view> -->
    </view>

    <!-- 功能模块 -->
    <view class="modules">
		<view class="module green-bg" id="userMangerButton">
		  <text class="module-title">闪赋二维码</text><br>
		
		  <u-button size="small"  style="margin-top: 20px;width: 100px;"  type="primary" @click="toAdmin_user">用户管理</u-button>
		</view>
      <view class="module blue-bg" id="showshanfu">
        <text class="module-title">闪赋二维码</text><br>
        <text class="module-desc">您的生意推广好帮手</text>
		<u-button size="small"  style="margin-top: 20px;width: 100px;" type="primary" @click="addOrignal">立即制作</u-button>
   
      </view>
<!-- 
      <view class="module green-bg">
        <text class="module-title">转让闪赋次数</text><br>
        <text class="module-desc">转让给他人 省时更省心</text>
        <u-button type="primary">立即转让</u-button>
      </view> -->

      <view class="module orange-bg">
        <text class="module-title">原码列表</text><br>
        <text class="module-desc">管理查看已上传的原码</text>

		<u-button size="small"  style="margin-top: 20px;width: 100px;" type="primary" @click="OriginalQRManager">原码管理</u-button>
		   
      </view>

     <view class="module blue-bg">
        <text class="module-title">转让记录</text><br>
        <text class="module-desc">查看充值转让记录</text>

		<u-button size="small" style="margin-top: 20px;width: 100px;" type="primary" @click="">立即查看</u-button>
		
      </view>
    </view>
  </view>
</template>

<script>
	import {addExandManager} from '@/api/system/exandManager.js'
	import {listOriginalQRcode} from '@/api/system/originalQRcode.js'
export default {
	 onLoad(options) {
	 this.getTotalVailbleOriginalCount()
	 
	 	},
    onReady: function() {
		this.showUserManagerButton()
		
    },
	data() {
	  return {
	    user: this.$store.state.user,
		totalVailbleCodeNumber:"",
		
	    
	  }
	},

	methods: {
		getTotalVailbleOriginalCount(){
			listOriginalQRcode({
		
				pageNum: 1,
				pageSize: 1000,
				
				state: "0"
			}).then(response => {
				this.totalVailbleCodeNumber = response.total
			})
		},
		OriginalQRManager(){
				uni.navigateTo({
					url: '/pages/home/admin/originalQR/OriginalQRManager',
					
				})
			},
		showUserManagerButton(){
			if(this.user.roles[0] == "admin"){
					document.getElementById("userMangerButton").style.display = "block";
					document.getElementById("showshanfu").style.display = "block";
				}else{
					document.getElementById("userMangerButton").style.display = "none";
					document.getElementById("showshanfu").style.display = "none";
				}
		},
		 // object转console.log(": " + JSON.stringify())  ;
	handleClick(){
	uni.navigateTo({
		url: '/pages/home/client/shoper/index',
		
	})
	},
	testTable(){
	uni.navigateTo({
		url: '/pages/table',
		
	})
	},
	addOrignal(){
		uni.navigateTo({
			url: '/pages/home/admin/originalQR/addOriginalQR',
			
		})
	},
	toAdmin_user(){
	uni.navigateTo({
		url: '/pages/home/admin/user/index',
		
	})
	},

	
	OriginalQRManager(){
		uni.navigateTo({
			url: '/pages/home/admin/originalQR/OriginalQRManager',
			
		})
	},
	
	showpay(){
		uni.navigateTo({
			url: '/pages/shanfu/showPay',
			
		})
	},

	

	logout(){
		this.$store.dispatch('LogOut').then(() => {
			uni.reLaunch({
				url: '/pages/index'
			})
		})
	}
	}
  }
</script>

<style>
.page {
  background-color: #f8f8f8;
  height: 100vh;
  padding: 20px;
}

.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #00aaff;
  padding: 20rpx;
  color: #fff;
}

.avatar {
  flex: 1;
}

.avatar-img {
  width: 100rpx;
  height: 100rpx;
  border-radius: 50%;
}

.user-details {
  flex: 3;
  padding-left: 20rpx;
}

.settings {
  flex: 1;
}

.stats {
  display: flex;
  justify-content: space-around;
  background-color: #00aaff;
  padding: 20rpx 0;
  color: #fff;
}

.stat-item {
  text-align: center;
}

.modules {
  margin-top: 50rpx;
}

.module {
  background-color: #fff;
  padding: 30rpx;
  border-radius: 10rpx;
  box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  margin-bottom: 20rpx;
  text-align: center;
}

.module-title {
  font-size: 32rpx;
  font-weight: bold;
}

.module-desc {
  margin: 10rpx 0 20rpx;
  font-size: 28rpx;
  color: #666;
}

.green-bg {
  background-color: #e0f7e0;
}

.blue-bg {
  background-color: #e0f0ff;
}

.yellow-bg {
  background-color: #fffde0;
}

.orange-bg {
  background-color: #ffe0cc;
}

u-button {
  width: 100%;
}
</style>
